{%- macro main_menu(data,hierarchy,root) %}
    {% for key, value in hierarchy %}
        <li{% if data[key]['hr'] is defined %} class="hr"{% endif %}>
            <a href="{{ url(data[key]['href']) }}">{% if data[key]['attach']['icon'] is defined AND data[key]['attach']['icon'] %}<i class="{{ data[key]['attach']['icon'] }}"></i>{% endif %} {{ data[key]['name'] }} {% if key != value %}<i class="fa {% if root === true %}fa-angle-down{% else %}fa-arrow-circle-right{% endif %}"></i>{% endif %}
            </a>
            {% if key != value %}
                <ul class="sub-menu">
                    {{ main_menu(data,value,false) }}
                </ul>
            {% endif %}
        </li>
    {% endfor %}
{%- endmacro %}
{{ main_menu(data,hierarchy,true) }}